import { useMemo } from 'react'
import { IToolPanelColumnCompParams } from '@ag-grid-community/core'

import { ICusAgGridProps } from '@/components/CusAgGrid'
import { IOrderListItem } from '../interface'

export const useSideBar = () => {
  return useMemo<ICusAgGridProps<IOrderListItem>['sideBar']>(() => {
    return {
      toolPanels: [
        {
          id: 'columns',
          labelDefault: '列显示配置',
          labelKey: '', // 有意使用无效 key，自动取 labelDefault
          iconKey: 'columns',
          toolPanel: 'agColumnsToolPanel',
          width: 200,
          minWidth: 200,
          maxWidth: 200 * 2,
          toolPanelParams: {
            suppressColumnMove: true,
            suppressRowGroups: true,
            suppressValues: true,
            suppressPivotMode: true,
          } satisfies Partial<IToolPanelColumnCompParams>,
        },
      ],
    }
  }, [])
}
